package masterjava.common.client.gxt.highstock;

import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.user.client.Element;
import masterjava.common.client.gxt.base.combo.GenericComboBox;
import masterjava.common.client.gxt.base.model.GenericListener;

/**
 * User: gkislin
 * Date: 8/2/11
 */
public class StyledHighStockTab extends LayoutContainer implements HighStockChartGetter {
    private final HighStockChart chart;

    public StyledHighStockTab(HighStockChart chart) {
        this.chart = chart;
    }

    @Override
    protected void onRender(Element parent, int pos) {
        super.onRender(parent, pos);
        add(createToolBar());
        add(chart);
    }

    protected ToolBar createToolBar(){
        ToolBar tb = new ToolBar();
        tb.add(new Label("Style:&nbsp"));
        GenericComboBox<HighStockSeriesType> combo =
                new GenericComboBox<HighStockSeriesType>(HighStockSeriesType.values());
        combo.addListener(new GenericListener<HighStockSeriesType>() {
            @Override
            public void onEvent(HighStockSeriesType type) {
                chart.setType(type);
            }
        });
        tb.add(combo);
        return tb;
    }

    @Override
    public HighStockChart getChart() {
        return chart;
    }
}
